package com.feihao.demoDate;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;

public class TestBirthday {
    public static void main(String[] args) throws ParseException {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入您的出生日期，格式为：yyyy-MM-dd");
        String birthday = scanner.next();

        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");

       /* Date parse = simpleDateFormat.parse(birthday);
        long time = parse.getTime();*/

       //出生日期解析为Data对象，再获取毫秒值。
        long time = simpleDateFormat.parse(birthday).getTime();


        //当前时间：
        long time1 = new Date().getTime();

        //出生到现在一共多少毫秒：

        long l = time1 - time;

        int day = (int) (l/1000/60/60/24);

        System.out.println("活了"+day);
    }
}
